#include "../Logs/zylog.h"
#include <unistd.h>

void test_log(const std::string name){
    INFO("%s","测试开始");
    zylog::Logger::ptr logger=zylog::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s","测试日志");
    logger->info("%s","测试日志");
    logger->warn("%s","测试日志");
    logger->error("%s","测试日志");
    logger->fatal("%s","测试日志");
    INFO("%s","测试完毕");
};

int main(){

   std::unique_ptr<zylog::LoggerBuilder> builder(new zylog::GlobalLoggerBuilder());
    builder->buildLoggerName("async_logger");
    builder->buildLoggerLevel(zylog::LogLevel::value::DEBUG);
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(zylog::LoggerType::LOGGER_SYNC);
    builder->buildSink<zylog::FileSink>("./logfile/test.log");
    builder->buildSink<zylog::StdoutSink>();
    builder->buildSink<zylog::RollBySizeSink>("./logfile/roll-async-by-size",1024*1024);
    builder->build();

    test_log("async_logger");
    
    return 0;
}
